package com.wqz.service.impl;

import com.wqz.dao.AddressDao;
import com.wqz.pojo.Address;
import com.wqz.service.AddressService;
import com.wqz.utils.MessageJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    private AddressDao addressDao;
    @Override
    public MessageJson<List<Address>> findAll() {

        List<Address> addressList = null;
        MessageJson<List<Address>> messageJson = null;
        try {
            addressList = addressDao.findAll();
            messageJson = new MessageJson<>("200", "请求成功。", addressList);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return messageJson;
    }

    @Override
    public MessageJson<List<Address>> findByAddressDesc(String addressDesc) throws Exception {
        List<Address> addressList = null;
        MessageJson<List<Address>> messageJson = null;
        try {
            addressList = addressDao.findByAddressDesc(addressDesc);
            messageJson = new MessageJson<>("200", "请求成功。", addressList);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return messageJson;
    }
}
